package test.drawapi
{
	import flash.display.BitmapData;

	public class DrawTriangles
	{
		public function DrawTriangles()
		{
		}
		setupTrangles();
		
		function setupTrangles():void
		{
			//三角形的顶点
			var verts:Vector.<Number> = new Vector.<Number>();
			verts.push(0,0);
			verts.push(32,0-17);
			verts.push(0,70);
			verts.push(32,70-17);
			//索引;
			var indices:Vector.<int> = new Vector.<int>();
			indices.push(0,1,2);
			indices.push(1,2,3);
			//uvt,每个顶点的纹理坐标[0,1];
			var uvt:Vector.<Number> = new Vector.<Number>();
			uvt.push(0,0);
			uvt.push(1,0);
			uvt.push(0,1);
			uvt.push(1,1);
			
			drawTriangle(verts,indices,uvt,new PersonHead());
		}
		function drawTriangle(verts:Vector.<Number>,indices:Vector.<int>,uvt:Vector.<Number>,tex:BitmapData):void{
			graphics.clear();
			graphics.lineStyle(1,0xff0000);
			//三角的绘制;
			graphics.beginBitmapFill(tex);
			//graphics.beginFill(0xff0000); //纯色,渐变填充不需要uv;
			graphics.drawTriangles(verts,indices,uvt);
			graphics.endFill();
		}
	}
}